/*******************************************************************
 * 外语翻译平台(translate) 
 *
 * 成都一亿信息技术公司 版权所有
 *
 * Copyright (C) 2010 Transer Information Technology Co., Ltd.
 *
 * @Version : 1.0 2010-12-29 上午11:08:05
 *
 * SignSuccessAction.java 
 *
 *
 *******************************************************************/
package com.transer.web.action.signup;

import org.apache.commons.lang.xwork.StringUtils;

import com.transer.console.ConsoleConstants;
import com.transer.job.ReSendMailJob;
import com.transer.persistance.dao.IUserDao;
import com.transer.utils.JobQueueOB;
import com.transer.web.action.TranserActionSupport;

/**
 * class defination are there
 * 
 * @author Mark
 * 
 * @version 1.0 ywengineer@gmail.com
 * 
 */
public class SignSuccessAction extends TranserActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 850642607921301203L;
	// email地址
	private String email;
	// email网址
	private String emailWebSite;
	// 用户操作
	protected IUserDao userDao;

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	@Override
	public String execute() throws Exception {
		// Email不为空并且包含@
		if (!StringUtils.isEmpty(email) && StringUtils.contains(email, "@")) {
			// 网址
			String suffix = StringUtils.substring(email, StringUtils.indexOf(email, "@") + 1);
			// gmail账号特殊处理
			if (suffix.equals("gmail.com")) {
				suffix = "google.com";
			}
			// 构建网址
			emailWebSite = "mail." + suffix;
		}
		return TranserActionSupport.SUCCESS;
	}

	/**
	 * 重新发送激活邮件
	 * 
	 * @return 结果
	 * @throws Exception
	 */
	public String resendEmail() throws Exception {
		// 如果邮箱不为空
		if (!StringUtils.isEmpty(email) && StringUtils.contains(email, "@")) {
			// 添加发送邮件
			JobQueueOB.getInstance().addJob(ConsoleConstants.QUEUE_INDEX_SAVE_USER, new ReSendMailJob(userDao, email));
		}
		return TranserActionSupport.SUCCESS;
	}

	/**
	 * @return the email
	 */
	public String getEmail() {
		return email;
	}

	/**
	 * @param email
	 *            the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return the emailWebSite
	 */
	public String getEmailWebSite() {
		return emailWebSite;
	}

	/**
	 * @param emailWebSite
	 *            the emailWebSite to set
	 */
	public void setEmailWebSite(String emailWebSite) {
		this.emailWebSite = emailWebSite;
	}

	/**
	 * @return the userDao
	 */
	public IUserDao getUserDao() {
		return userDao;
	}

	/**
	 * @param userDao
	 *            the userDao to set
	 */
	public void setUserDao(IUserDao userDao) {
		this.userDao = userDao;
	}
}